<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 表单验证 jQuery Validation</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css-v=3.3.5.css"
          tppabs="http://www.zi-han.net/theme/hplus/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="css/font-awesome.min.css-v=4.4.0.css"
          tppabs="http://www.zi-han.net/theme/hplus/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.min.css" tppabs="http://www.zi-han.net/theme/hplus/css/animate.min.css"
          rel="stylesheet">
    <link href="css/style.min.css-v=4.0.0.css" tppabs="http://www.zi-han.net/theme/hplus/css/style.min.css?v=4.0.0"
          rel="stylesheet">
    <!--	<base target="_blank">-->
    <link rel="stylesheet" type="text/css" href="./layui/css/layui.css"/>
    <style>
        #zhuti{
            height:100%;

        }
        #zhuti::before{
            background:  url('img/logo1.png')  no-repeat fixed center;
            content:"";
            opacity:0.2;
        /*//透明度设置*/
        /*z-index:-1;*/
            width:80%;
            height:100%;
            position:absolute;
            /*top:0px;*/
            /*left:0px;*/
            /*border-radius:40px*/
        }
        #xiaohuiid{
            border-top: 0;
            padding-left: 20px;
            height:360px;
            background-color: #fff;
            margin-right: -15px;
            margin-left: -15px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" id="zhuti">
                <div class="ibox-title">
                    <h4 style="font-weight: 600;margin-top: 0;">申请延时</h4>
                </div>
                <div class="alert alert-danger" style="margin-bottom: 0;text-align: center;">
                    成功提交延时申请后，请尽快拨打联系电话：8048022 &nbsp;&nbsp;&nbsp;&nbsp;8249177。
                </div>
                <div class="ibox-content">
                    <div class="form-horizontal m-t" id="commentForm">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">会议名称：</label>
                            <div class="col-sm-8">
                                <input readonly="readonly" id="hname" name="name" minlength="2" type="text"
                                       class="form-control"
                                       required="" aria-required="true">
                            </div>
                        </div>
                        <div class="form-group" id="laydate">
                            <label class="col-sm-3 control-label">会议结束时间：</label>
                            <div class="col-sm-8">
                                <input type="text" placeholder="yyyy-MM-dd HH:mm:ss" class="form-control"
                                       id="test2" required="" aria-required="true" name="time">
                            </div>
                        </div>
                        <div class="form-group" id="sm">
                            <label class="col-sm-3 control-label">说明：</label>
                            <div class="col-sm-8">
                                <textarea id="comment" name="comment" class="form-control"></textarea>
                            </div>
                        </div>
                        <div id="shzt">

                        </div>
                        <div class="form-group" id="btn">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button id="sub" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <a target="_self" href="meetingState.html">
                                    <input type="submit"
                                           class="btn btn-info"
                                           value="返回">
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="layui/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="./layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.min.js-v=2.1.4" tppabs="http://www.zi-han.net/theme/hplus/js/jquery.min.js?v=2.1.4">
</script>
<!--<script type="text/javascript">-->
<!--    -->
<!--</script>-->
<script src="js/bootstrap.min.js-v=3.3.5"
        tppabs="http://www.zi-han.net/theme/hplus/js/bootstrap.min.js?v=3.3.5"></script>
<script>
    let id = 0;
    let starttime=''
    let endtime = '';
    let delaystate = ''
    let state=''


    <!--    拆分时间字符串-->
    function stringToTime(str) {
        var date = str;
        date = date.substring(0, 19);
        date = date.replace(/-/g, '/');
        date = date.replace(/:/g, '/');
        date = date.replace(/\s/g, "/");
        var a = date.split('/');
        return a;
    };

    <!--	获取url后边的参数-->
    function GetRequest() {
        const url = location.search; //获取url中"?"符后的字串
        let theRequest = new Object();
        if (url.indexOf("?") != -1) {
            let str = url.substr(1);
            let strs = str.split("&");
            for (let i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }


    $(document).ready(function (ev) {
        let x = GetRequest();
        console.log(x);
        id = x.id;
        let mid = x.mid;


            //获取状态
        $.ajax({
            type: "POST",
            // url: "/user/findDelay",
            url:"/user/getOneDelay",
            data: {
                id: parseInt(id),
            },
            success: function (msg) {
                state=msg.state
                $('#hname').val(msg.name)
                console.log(msg)
                starttime=msg.starttime
                delaystate = msg.delaystate
                console.log(delaystate)
                if (msg != '') {
                    if (msg.delaystate != null) {
                        $('#test2').val(msg.delaytime);
                        $('#test2').attr('disabled', 'disabled');
                        $('#sm').remove();
                        $('#sub').attr('disabled',true);
                        let spzt = "<div class=\"form-group\">\n" +
                            "                            <label class=\"col-sm-3 control-label\">审核状态：</label>\n" +
                            "                            <div class=\"col-sm-8\">\n" +
                            "                                <input value=" + msg.delaystate + " readonly=\"readonly\" id=\"cname\" name=\"name\" minlength=\"2\" type=\"text\"\n" +
                            "                                       class=\"form-control\"\n" +
                            "                                       required=\"\" aria-required=\"true\">\n" +
                            "                            </div>\n" +
                            "                        </div>"
                        $('#shzt').append(spzt);
                        $('#cname').val(msg.delaystate);
                    }
                }
            }
        });

        endtime = x.endtime;
        // console.log(endtime);
    }),

        //时间日期选择器(被顺序执行了)
        layui.use('laydate', function () {
            let laydate = layui.laydate;
            laydate.render({
                elem: '#test2',
                type: 'datetime',
                min: endtime,
                max: 60
            });
        })

    //获取当前时间，转成字符串
    function gettime(){
        //判断是否在前面加0
        function getNow(s) {
            return s < 10 ? '0' + s: s;
        }
        var myDate = new Date();
        var year=myDate.getFullYear();        //获取当前年
        var month=myDate.getMonth()+1;   //获取当前月
        var date=myDate.getDate();            //获取当前日
        var h=myDate.getHours();              //获取当前小时数(0-23)
        var m=myDate.getMinutes();          //获取当前分钟数(0-59)
        var s=myDate.getSeconds();
        var now=year+'-'+getNow(month)+"-"+getNow(date)+" "+getNow(h)+':'+getNow(m)+":"+getNow(s);
        return now
    }

    $("#sub").on("click", function () {


        var time = $("input[name='time']").val();

        // if(state=="审批通过")
        console.log(starttime,endtime, state);
        let sj=gettime();
        console.log(sj)
        console.log(typeof starttime);
        console.log(starttime>endtime);
        if(state=='审批通过' && sj>starttime && sj<endtime) {
            if (time != null) {
                $.ajax({
                    type: "POST",
                    url: "/user/delay",
                    data: {
                        id: parseInt(id),
                        d: time
                    },
                    success: function (msg) {
                        let xx = ''
                        if (msg) {
                            xx = '提交成功！';
                        } else {
                            xx = '请缩短会议延时时间！';
                        }
                        layer.alert(xx);
                        $('#sub').attr('disabled', true);
                    }
                });
            }
        }else{
            layer.alert("会议未开始或已结束，无法延时！");
        }
    })
</script>
</body>

</html>
